"""
@Author：十
@Time：2025/8/20 14:52
@FileName：showDevice.py
@Description：显示主机传感器列表
"""
import sys

from PyQt5.QtCore import Qt, QPoint
from PyQt5.QtGui import QMouseEvent
from PyQt5.QtWidgets import QWidget, QApplication
from UI.showDevice import Ui_widget
import resource.WTC_rc

class ShowDevice(QWidget, Ui_widget):
    def __init__(self, parent=None):
        super(ShowDevice, self).__init__()
        self.setupUi(self)

        self.parent = parent

    def showWindow(self):
        self.show()

    def get_sensor_host(self):
        self.parent.parent.Serial_Thread.send_data(bytes.fromhex("0103044D0078D4CF"), immediate=True)

    def mouseMoveEvent(self, e: QMouseEvent):  # 重写移动事件
        if self._tracking:
            self._endPos = e.pos() - self._startPos
            self.move(self.pos() + self._endPos)

    def mousePressEvent(self, e: QMouseEvent):
        if e.button() == Qt.LeftButton:
            self._startPos = QPoint(e.x(), e.y())
            self._tracking = True

    def mouseReleaseEvent(self, e: QMouseEvent):
        if e.button() == Qt.LeftButton:
            self._tracking = False
            self._startPos = None
            self._endPos = None


if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = ShowDevice()
    mainWindow.show()
    sys.exit(app.exec_())
